<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
<!--
前面会为每个待办项渲染同样的文本，这看起来并不炫酷
我们应该能把数据从父组件传到子组件才对
-->
<div id="app-8">
    <todo-item v-for="item in groceryList" v-bind:todo="item" v-bind:key="item.id"></todo-item>
</div>

<script type="text/javascript">
    /*
    * 定义可以接受一个参数，叫 todo
    * */
    Vue.component('todo-item', {
        props: ['todo'],
        template: '<li>{{ todo.text }}</li>'
    });

    var app8 = new Vue({
        el: '#app-8',
        data: {
            groceryList: [
                {id: 0, text: '蔬菜'},
                {id: 1, text: '奶酪'},
                {id: 2, text: '随便其它什么人吃的东西'}
            ]
        }
    })
</script>
</body>
</html>
